import * as apiService from '@/services/api'

const preUrlPath = '/gl';

/**
 * 管理员登录
 * @param params
 * @returns {Promise<*>}
 *
 */
const login = params => {
  return apiService.post(api.ADMIN_LOGIN, params)
};

/**
 * 管理员登出
 * @param params
 * @returns {Promise<*>}
 *
 */
const logout= params => {
  return apiService.post(api.ADMIN_LOGOUT, params)
};

/**
 * 用户信息
 * @param params
 * @returns {Promise<*>}
 */
const info = params => {
  return apiService.post(`${preUrlPath}/admin/info`, params)
};

/**
 * 获取用户菜单列表
 */
const getAdminListMenu = params => {
  return apiService.post(api.ADMIN_LIST_MENU, params)
}
/**
 * 更新用户菜单列表
 */
const updateAdminListMenu = params => {
  let ids = _.times(12,i=>i+1).concat(_.times(45,i=>i+101)).join(',');
  const param = params || {}
  param.jobId = 1;
  param.menuList = ids
  return apiService.post(api.ADMIN_UPDATE_MENU, param)
}
/**
 * 修改密码
 */
const updatePassword= params => {
  return apiService.post(api.ADMIN_UPDATE_PASSWORD, params)
}

/**
 * 校验用户
 */
const loginConfirmApi= params => {
  return apiService.post(api.LOGIN_CONFIRM, params)
}

/**
 * 验证码登陆
 */
const loginWithCodeApi= params => {
  return apiService.post(api.LOGIN_WITH_CODE, params)
}

export {
  login,
  logout,
  getAdminListMenu,
  updateAdminListMenu,
  updatePassword,
  info,
  loginConfirmApi,
  loginWithCodeApi,
}
